<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="t" %>

<t:body title="Лекция">
	<div class="c_block">
		<div class="title">Лекция</div>
		<c:url value="/course/${course.id}/lection/${lection.id > 0 ? lection.id : 'new'}" var="url"/>
		<form:form modelAttribute="lection" enctype="multipart/form-data" action="${url}">
			<t:input name="Имя" path="name">
				<form:input path="name" size="30" maxlength="80"/>
			</t:input>
			
			<div class="row">
				<div class="simple_l">Презентации</div>
				<div class="simple_d">
				
					<c:forEach var="file" items="${lection.presentationFiles}">
						<div class="logical_conteiner file_conteiner">
					 		<input type="hidden" name="presentation[]" value="${file.id}">
				       		<c:url var="url" value="/file/${file.id}/${file.fileName}"/>
				       		<a href="${url}"><c:out value="${file.fileName}"/></a>
							<span class="del_file" onclick="del_file_input(this);" >X</span>
			       		</div>
			       	</c:forEach>
			       	
					<div class="logical_conteiner file_input_conteiner">
						<input type="file" name="presentation1" class="file_input" onchange="add_file_input(this, '#presentation_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
					</div> 
					<div class="hiden" id="presentation_pattern">
						<div class="logical_conteiner file_input_conteiner">
							<input type="file" name="presentation0" class="file_input" onchange="add_file_input(this, '#presentation_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
						</div>
					</div>
				</div>
			</div>
			
			<div class="row">
				<div class="simple_l">Вопросы</div>
				<div class="simple_d">
				
					<c:forEach var="file" items="${lection.questionFiles}">
						<div class="logical_conteiner file_conteiner">
					 		<input type="hidden" name="question[]" value="${file.id}">
				       		<c:url var="url" value="/file/${file.id}/${file.fileName}"/>
				       		<a href="${url}"><c:out value="${file.fileName}"/></a>
							<span class="del_file" onclick="del_file_input(this);" >X</span>
			       		</div>
			       	</c:forEach>
			       	
					<div class="logical_conteiner file_input_conteiner">
						<input type="file" name="question1" class="file_input" onchange="add_file_input(this, '#question_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
					</div> 
					<div class="hiden" id="question_pattern">
						<div class="logical_conteiner file_input_conteiner">
							<input type="file" name="question0" class="file_input" onchange="add_file_input(this, '#question_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
						</div>
					</div>
				</div>
			</div>
			
			<div class="row">
				<div class="simple_l">Дополнительно</div>
				<div class="simple_d">
				
					<c:forEach var="file" items="${lection.otherFiles}">
						<div class="logical_conteiner file_conteiner">
					 		<input type="hidden" name="other[]" value="${file.id}">
				       		<c:url var="url" value="/file/${file.id}/${file.fileName}"/>
				       		<a href="${url}"><c:out value="${file.fileName}"/></a>
							<span class="del_file" onclick="del_file_input(this);">X</span>
			       		</div>
			       	</c:forEach>
			       	
					<div class="logical_conteiner file_input_conteiner">
						<input type="file" name="other1" class="file_input" onchange="add_file_input(this, '#other_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
					</div> 
					<div class="hiden" id="other_pattern">
						<div class="logical_conteiner file_input_conteiner">
							<input type="file" name="other0" class="file_input" onchange="add_file_input(this, '#other_pattern');" size="15">
							<span class="del_file" onclick="del_file_input(this);" style="display: none;">X</span>
						</div>
					</div>
				</div>
			</div>
			
			
		
			<%--<t:fileInput name="presentation" label="Презентация" items="${lection.presentationFiles}"></t:fileInput>
			<t:fileInput name="question" label="Вопросы"></t:fileInput>
			<t:fileInput name="other" label="Другое"></t:fileInput>--%>
			<span class="last">
				<span class="link" onclick="document.forms[0].submit();" style="paddind: 5px 15px;">Сохранить</span>
				<span class="link" onclick="history.back()">Назад</span>
			</span>
		</form:form>
	</div>
</t:body>

